package com.github.catvod.spider.merge;

import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.regex.Pattern;
import javax.annotation.Nullable;

public class Lm extends fa {
  private static final Pattern I;
  
  private static final String oC;
  
  private static final List<Lm> q = Collections.emptyList();
  
  private iP BQ;
  
  @Nullable
  private QF Qy;
  
  @Nullable
  private WeakReference<List<Lm>> W;
  
  List<fa> u;
  
  static {
    I = Pattern.compile("\\s+");
    oC = QF.j5("baseUri");
  }
  
  public Lm(iP paramiP, String paramString) {
    this(paramiP, paramString, null);
  }
  
  public Lm(iP paramiP, @Nullable String paramString, @Nullable QF paramQF) {
    R2.u(paramiP);
    this.u = fa.h;
    this.Qy = paramQF;
    this.BQ = paramiP;
    if (paramString != null)
      F(paramString); 
  }
  
  private static String Gg(Lm paramLm, String paramString) {
    while (paramLm != null) {
      QF qF = paramLm.Qy;
      if (qF != null && qF.t(paramString))
        return paramLm.Qy.oq(paramString); 
      paramLm = paramLm.lu();
    } 
    return "";
  }
  
  private static void M(Lm paramLm, StringBuilder paramStringBuilder) {
    if (paramLm.BQ.j().equals("br") && !IG.SS(paramStringBuilder))
      paramStringBuilder.append(" "); 
  }
  
  private boolean S(HZ.Tw paramTw) {
    boolean bool;
    if (XA().BQ() && !XA().I() && (lu() == null || lu().rG()) && Ig() != null && !paramTw.BQ()) {
      bool = true;
    } else {
      bool = false;
    } 
    return bool;
  }
  
  private static <E extends Lm> int Xu(Lm paramLm, List<E> paramList) {
    int i = paramList.size();
    for (byte b = 0; b < i; b++) {
      if (paramList.get(b) == paramLm)
        return b; 
    } 
    return 0;
  }
  
  private boolean Y(HZ.Tw paramTw) {
    return (this.BQ.V0() || (lu() != null && lu().XA().V0()) || paramTw.BQ());
  }
  
  private void Yd(StringBuilder paramStringBuilder) {
    for (fa fa1 : this.u) {
      if (fa1 instanceof IG) {
        ap(paramStringBuilder, (IG)fa1);
        continue;
      } 
      if (fa1 instanceof Lm)
        M((Lm)fa1, paramStringBuilder); 
    } 
  }
  
  private static void ap(StringBuilder paramStringBuilder, IG paramIG) {
    String str = paramIG.M();
    if (vm(paramIG.V0) || paramIG instanceof ok) {
      paramStringBuilder.append(str);
      return;
    } 
    ZG.h(paramStringBuilder, str, IG.SS(paramStringBuilder));
  }
  
  static boolean vm(@Nullable fa paramfa) {
    if (paramfa instanceof Lm) {
      paramfa = paramfa;
      byte b = 0;
      while (true) {
        if (((Lm)paramfa).BQ.oq())
          return true; 
        Lm lm = paramfa.lu();
        if (++b < 6) {
          paramfa = lm;
          if (lm == null)
            break; 
          continue;
        } 
        break;
      } 
    } 
    return false;
  }
  
  @Nullable
  public Lm B() {
    if (this.V0 == null)
      return null; 
    List<Lm> list = lu().i();
    int i = Xu(this, list);
    return (i > 0) ? list.get(i - 1) : null;
  }
  
  public Lm C() {
    this.u.clear();
    return this;
  }
  
  @Nullable
  public Lm DQ(String paramString) {
    return CR.j(paramString, this);
  }
  
  public Lm HU(String paramString1, String paramString2) {
    q(paramString1, paramString2);
    return this;
  }
  
  public QF I() {
    if (this.Qy == null)
      this.Qy = new QF(); 
    return this.Qy;
  }
  
  public List<IG> J() {
    ArrayList<IG> arrayList = new ArrayList();
    for (fa fa1 : this.u) {
      if (fa1 instanceof IG)
        arrayList.add((IG)fa1); 
    } 
    return Collections.unmodifiableList(arrayList);
  }
  
  public Dv K() {
    if (this.V0 == null)
      return new Dv(0); 
    List<Lm> list = lu().i();
    Dv dv = new Dv(list.size() - 1);
    for (Lm lm : list) {
      if (lm != this)
        dv.add(lm); 
    } 
    return dv;
  }
  
  public String MC() {
    return this.BQ.j();
  }
  
  public int N() {
    return (lu() == null) ? 0 : Xu(this, lu().i());
  }
  
  public Dv O() {
    return zt.h(new ms.Tw(), this);
  }
  
  void Og(Appendable paramAppendable, int paramInt, HZ.Tw paramTw) {
    if (paramTw.u() && Y(paramTw) && !S(paramTw))
      if (paramAppendable instanceof StringBuilder) {
        if (((StringBuilder)paramAppendable).length() > 0)
          j5(paramAppendable, paramInt, paramTw); 
      } else {
        j5(paramAppendable, paramInt, paramTw);
      }  
    paramAppendable.append('<').append(MC());
    QF qF = this.Qy;
    if (qF != null)
      qF.i4(paramAppendable, paramTw); 
    if (this.u.isEmpty() && this.BQ.u()) {
      if (paramTw.Qy() == HZ.Tw.Tw.h && this.BQ.I()) {
        paramAppendable.append('>');
      } else {
        paramAppendable.append(" />");
      } 
    } else {
      paramAppendable.append('>');
    } 
  }
  
  public String Oh() {
    StringBuilder stringBuilder = ZG.V0();
    Yd(stringBuilder);
    return ZG.t(stringBuilder).trim();
  }
  
  public Lm P() {
    return (Lm)super.z();
  }
  
  public String PU() {
    return this.BQ.j();
  }
  
  public Dv Pi(String paramString) {
    return CR.h(paramString, this);
  }
  
  void R(Appendable paramAppendable, int paramInt, HZ.Tw paramTw) {
    if (!this.u.isEmpty() || !this.BQ.u()) {
      if (paramTw.u() && !this.u.isEmpty() && (this.BQ.V0() || (paramTw.BQ() && (this.u.size() > 1 || (this.u.size() == 1 && !(this.u.get(0) instanceof IG))))))
        j5(paramAppendable, paramInt, paramTw); 
      paramAppendable.append("</").append(MC()).append('>');
    } 
  }
  
  public Lm SS(fa paramfa) {
    return (Lm)BQ(paramfa);
  }
  
  public iP XA() {
    return this.BQ;
  }
  
  public String a() {
    String str;
    QF qF = this.Qy;
    if (qF != null) {
      str = qF.F8("id");
    } else {
      str = "";
    } 
    return str;
  }
  
  public Lm d1(int paramInt) {
    return i().get(paramInt);
  }
  
  public String e() {
    StringBuilder stringBuilder = ZG.V0();
    bY.V0(new Tw(this, stringBuilder), this);
    return ZG.t(stringBuilder).trim();
  }
  
  protected Lm fR(@Nullable fa paramfa) {
    Lm lm = (Lm)super.F8(paramfa);
    QF qF = this.Qy;
    if (qF != null) {
      qF = qF.u();
    } else {
      qF = null;
    } 
    lm.Qy = qF;
    yh yh = new yh(lm, this.u.size());
    lm.u = yh;
    yh.addAll(this.u);
    return lm;
  }
  
  public String g6() {
    StringBuilder stringBuilder = ZG.V0();
    for (fa fa1 : this.u) {
      if (fa1 instanceof BG) {
        stringBuilder.append(((BG)fa1).M());
        continue;
      } 
      if (fa1 instanceof mF) {
        stringBuilder.append(((mF)fa1).M());
        continue;
      } 
      if (fa1 instanceof Lm) {
        stringBuilder.append(((Lm)fa1).g6());
        continue;
      } 
      if (fa1 instanceof ok)
        stringBuilder.append(((ok)fa1).M()); 
    } 
    return ZG.t(stringBuilder);
  }
  
  public boolean hP(String paramString) {
    QF qF = this.Qy;
    if (qF == null)
      return false; 
    String str = qF.F8("class");
    int j = str.length();
    int i = paramString.length();
    if (j != 0 && j >= i) {
      if (j == i)
        return paramString.equalsIgnoreCase(str); 
      boolean bool = false;
      byte b2 = 0;
      byte b1 = 0;
      while (b1 < j) {
        boolean bool1;
        byte b;
        if (Character.isWhitespace(str.charAt(b1))) {
          bool1 = bool;
          b = b2;
          if (bool) {
            if (b1 - b2 == i && str.regionMatches(true, b2, paramString, 0, i))
              return true; 
            bool1 = false;
            b = b2;
          } 
        } else {
          bool1 = bool;
          b = b2;
          if (!bool) {
            b = b1;
            bool1 = true;
          } 
        } 
        b1++;
        bool = bool1;
        b2 = b;
      } 
      if (bool && j - b2 == i)
        return str.regionMatches(true, b2, paramString, 0, i); 
    } 
    return false;
  }
  
  List<Lm> i() {
    // Byte code:
    //   0: aload_0
    //   1: invokevirtual u : ()I
    //   4: ifne -> 11
    //   7: getstatic com/github/catvod/spider/merge/Lm.q : Ljava/util/List;
    //   10: areturn
    //   11: aload_0
    //   12: getfield W : Ljava/lang/ref/WeakReference;
    //   15: astore_3
    //   16: aload_3
    //   17: ifnull -> 37
    //   20: aload_3
    //   21: invokevirtual get : ()Ljava/lang/Object;
    //   24: checkcast java/util/List
    //   27: astore #4
    //   29: aload #4
    //   31: astore_3
    //   32: aload #4
    //   34: ifnonnull -> 116
    //   37: aload_0
    //   38: getfield u : Ljava/util/List;
    //   41: invokeinterface size : ()I
    //   46: istore_2
    //   47: new java/util/ArrayList
    //   50: dup
    //   51: iload_2
    //   52: invokespecial <init> : (I)V
    //   55: astore_3
    //   56: iconst_0
    //   57: istore_1
    //   58: iload_1
    //   59: iload_2
    //   60: if_icmpge -> 104
    //   63: aload_0
    //   64: getfield u : Ljava/util/List;
    //   67: iload_1
    //   68: invokeinterface get : (I)Ljava/lang/Object;
    //   73: checkcast com/github/catvod/spider/merge/fa
    //   76: astore #4
    //   78: aload #4
    //   80: instanceof com/github/catvod/spider/merge/Lm
    //   83: ifeq -> 98
    //   86: aload_3
    //   87: aload #4
    //   89: checkcast com/github/catvod/spider/merge/Lm
    //   92: invokeinterface add : (Ljava/lang/Object;)Z
    //   97: pop
    //   98: iinc #1, 1
    //   101: goto -> 58
    //   104: aload_0
    //   105: new java/lang/ref/WeakReference
    //   108: dup
    //   109: aload_3
    //   110: invokespecial <init> : (Ljava/lang/Object;)V
    //   113: putfield W : Ljava/lang/ref/WeakReference;
    //   116: aload_3
    //   117: areturn
  }
  
  protected List<fa> iU() {
    if (this.u == fa.h)
      this.u = new yh(this, 4); 
    return this.u;
  }
  
  public final Lm lu() {
    return (Lm)this.V0;
  }
  
  public <T extends Appendable> T nO(T paramT) {
    int i = this.u.size();
    for (byte b = 0; b < i; b++)
      ((fa)this.u.get(b)).LW((Appendable)paramT); 
    return paramT;
  }
  
  public String oC() {
    return Gg(this, oC);
  }
  
  public Lm r4() {
    return (Lm)super.oq();
  }
  
  public boolean rG() {
    return this.BQ.q();
  }
  
  public Lm rl(fa paramfa) {
    R2.u(paramfa);
    T(paramfa);
    iU();
    this.u.add(paramfa);
    paramfa.FE(this.u.size() - 1);
    return this;
  }
  
  public Dv s() {
    return new Dv(i());
  }
  
  protected void t(String paramString) {
    I().yx(oC, paramString);
  }
  
  public int u() {
    return this.u.size();
  }
  
  public String w() {
    return this.BQ.Qy();
  }
  
  protected boolean y() {
    boolean bool;
    if (this.Qy != null) {
      bool = true;
    } else {
      bool = false;
    } 
    return bool;
  }
  
  public String yp() {
    StringBuilder stringBuilder = ZG.V0();
    nO(stringBuilder);
    String str2 = ZG.t(stringBuilder);
    String str1 = str2;
    if (n.h(this).u())
      str1 = str2.trim(); 
    return str1;
  }
  
  void yx() {
    super.yx();
    this.W = null;
  }
  
  class Tw implements aC {
    final Lm V0;
    
    final StringBuilder h;
    
    Tw(Lm this$0, StringBuilder param1StringBuilder) {}
    
    public void V0(fa param1fa, int param1Int) {
      if (param1fa instanceof IG) {
        param1fa = param1fa;
        Lm.qG(this.h, (IG)param1fa);
      } else if (param1fa instanceof Lm) {
        param1fa = param1fa;
        if (this.h.length() > 0 && (param1fa.rG() || Lm.E((Lm)param1fa).j().equals("br")) && !IG.SS(this.h))
          this.h.append(' '); 
      } 
    }
    
    public void h(fa param1fa, int param1Int) {
      if (param1fa instanceof Lm && ((Lm)param1fa).rG() && param1fa.GM() instanceof IG && !IG.SS(this.h))
        this.h.append(' '); 
    }
  }
  
  private static final class yh extends hT<fa> {
    private final Lm h;
    
    yh(Lm param1Lm, int param1Int) {
      super(param1Int);
      this.h = param1Lm;
    }
    
    public void h() {
      this.h.yx();
    }
  }
}


/* Location:              /Users/hetaiyi/Desktop/my/tech/java/study/aa/temp/temp.jar!/com/github/catvod/spider/merge/Lm.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       1.1.3
 */